﻿<Window x:Class="TimeRecorderStatistics.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:timeRecorderStatistics="clr-namespace:TimeRecorderStatistics"
        Title="TimeRecorder Statistics" Icon="TimeRecorder.ico" Height="350" Width="525" SizeToContent="WidthAndHeight">
    <Window.Resources>
        <Style x:Key="CheckableMenuItemStyle" TargetType="MenuItem">
            <Setter Property="Header" Value="{Binding Header}"/>
            <Setter Property="IsChecked" Value="{Binding IsChecked}"/>
            <Setter Property="IsCheckable" Value="True"/>
        </Style>
    </Window.Resources>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="File">
                <MenuItem Header="Report" Command="{Binding CreateReportCommand}"/>
                <Separator/>
                <MenuItem Header="Exit" Command="{Binding ExitCommand}"/>
            </MenuItem>
            <MenuItem Header="Previous" Command="{Binding PreviousWeekCommand}"/>
            <MenuItem Header="Next" Command="{Binding NextWeekCommand}"/>
            <MenuItem Header="View">
                <MenuItem Header="Machines" ItemsSource="{Binding Machines}" ItemContainerStyle="{StaticResource CheckableMenuItemStyle}"/>
                <MenuItem Header="Categories" ItemsSource="{Binding Categories}" ItemContainerStyle="{StaticResource CheckableMenuItemStyle}"/>
                <MenuItem Header="Clear categories" Command="{Binding ClearCategoriesCommand}"/>
                <MenuItem IsCheckable="True" IsChecked="{Binding PerMachine}" Header="Per machine"/>
                <MenuItem IsCheckable="True" IsChecked="{Binding RenderSelectedOnly}" Header="Only selected categories"/>
            </MenuItem>
            <MenuItem Header="Tools">
                <MenuItem Header="Data folders"><TextBox Text="{Binding RootFolders}" Width="200"/></MenuItem>
            </MenuItem>
        </Menu>
        <ListBox DockPanel.Dock="Right" Margin="8" BorderThickness="0" Width="160" ItemsSource="{Binding Categories}" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox Content="{Binding Header}" IsChecked="{Binding IsChecked}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <ScrollViewer  Margin="8" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="120"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <StackPanel VerticalAlignment="Center">
                        <TextBlock Text="{Binding TimeInfo}"/>
                    </StackPanel>
                    <Image Grid.Column="1" Source="{Binding Header}" Stretch="None"/>
                </Grid>
                <ItemsControl ItemsSource="{Binding Week}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="120"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <StackPanel VerticalAlignment="Center">
                                    <TextBlock Text="{Binding Day}" FontWeight="Bold"/>
                                    <TextBlock Text="{Binding Date}"/>
                                    <TextBlock Text="{Binding TimeInfo}"/>
                                    <TextBlock Text="{Binding WorkHoursTimeInfo}" ToolTip="Time within regular work hours"/>
                                </StackPanel>
                                <Image Grid.Column="1" Source="{Binding Image}" timeRecorderStatistics:ToolTipBehavior.ToolTipSource="{Binding}" Stretch="None"/>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </ScrollViewer>
    </DockPanel>
</Window>
